package com.chuangxin.data.edu5156;

import com.chuangxin.data.core.IDBasedFetcher;
import com.chuangxin.data.core.io.DataOutput;
import com.chuangxin.data.core.io.FileWriter;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;

import java.io.File;

/**
 * Created by Dawnwords on 2015/2/4.
 */
public class CYFetcher extends IDBasedFetcher {
    private static final int start = 1;
    private static final int end = 31247;
    private static final String template = "http://cy.5156edu.com/html4/${id}.html";

    public CYFetcher(DataOutput output) {
        super(output, start, end, template);
    }

    @Override
    protected TitleContent processDoc(Document doc, String url) {
        Elements table = doc.select("table#table3 table tbody").eq(0);
        String title = table.select("b").eq(0).html();
        String content = table.html();
        return new TitleContent(title, content);
    }

    public static void main(String[] args) {
        new CYFetcher(new FileWriter("E:" + File.separator + "edu5156" + File.separator + "cy")).execute();
    }
}
